package com.vf.activity.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.vf.common.annotation.Log;
import com.vf.common.core.controller.BaseController;
import com.vf.common.core.domain.AjaxResult;
import com.vf.common.enums.BusinessType;
import com.vf.activity.domain.ActivityAttendance;
import com.vf.activity.service.IActivityAttendanceService;
import com.vf.common.utils.poi.ExcelUtil;
import com.vf.common.core.page.TableDataInfo;

/**
 * 活动考勤Controller
 * 
 * @author LBS
 * @date 2025-06-04
 */
@RestController
@RequestMapping("/activity/activityAttendance")
@Api(tags="活动考勤")
public class ActivityAttendanceController extends BaseController
{
    @Autowired
    private IActivityAttendanceService activityAttendanceService;

    /**
     * 查询活动考勤列表
     */
    @PreAuthorize("@ss.hasPermi('activity:activityAttendance:list')")
    @GetMapping("/list")
    public TableDataInfo list(ActivityAttendance activityAttendance)
    {
        startPage();
        List<ActivityAttendance> list = activityAttendanceService.selectActivityAttendanceList(activityAttendance);
        return getDataTable(list);
    }

    /**
     * 导出活动考勤列表
     */
    @PreAuthorize("@ss.hasPermi('activity:activityAttendance:export')")
    @Log(title = "活动考勤", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ActivityAttendance activityAttendance)
    {
        List<ActivityAttendance> list = activityAttendanceService.selectActivityAttendanceList(activityAttendance);
        ExcelUtil<ActivityAttendance> util = new ExcelUtil<ActivityAttendance>(ActivityAttendance.class);
        util.exportExcel(response, list, "活动考勤数据");
    }

    /**
     * 获取活动考勤详细信息
     */
    @PreAuthorize("@ss.hasPermi('activity:activityAttendance:query')")
    @GetMapping(value = "/{attendanceId}")
    public AjaxResult getInfo(@PathVariable("attendanceId") Long attendanceId)
    {
        return success(activityAttendanceService.selectActivityAttendanceByAttendanceId(attendanceId));
    }

    /**
     * 新增活动考勤
     */
    @PreAuthorize("@ss.hasPermi('activity:activityAttendance:add')")
    @Log(title = "活动考勤", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ActivityAttendance activityAttendance)
    {
        return toAjax(activityAttendanceService.insertActivityAttendance(activityAttendance));
    }

    /**
     * 修改活动考勤
     */
    @PreAuthorize("@ss.hasPermi('activity:activityAttendance:edit')")
    @Log(title = "活动考勤", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ActivityAttendance activityAttendance)
    {
        return toAjax(activityAttendanceService.updateActivityAttendance(activityAttendance));
    }

    /**
     * 删除活动考勤
     */
    @PreAuthorize("@ss.hasPermi('activity:activityAttendance:remove')")
    @Log(title = "活动考勤", businessType = BusinessType.DELETE)
	@DeleteMapping("/{attendanceIds}")
    public AjaxResult remove(@PathVariable Long[] attendanceIds)
    {
        return toAjax(activityAttendanceService.deleteActivityAttendanceByAttendanceIds(attendanceIds));
    }
}
